<?php
function Gen_File_Data(){
	$result = HEAD_NEWS;
	$result = $result . "<body></body>";
	$result = $result . END_NEWS;
	
	return $result;
}

function Create_File(){
	$my_file = fopen("html/news.html","w");
	fwrite($my_file,Gen_File_Data());
	fclose($my_file);
}

function Delete_Text($Topmenu_ID){
  mysql_query("DELETE FROM top_menu_text WHERE ((Type_ID=$Topmenu_ID) AND (Type='NEWS'))");
}

function Insert_Topmenu($Topmenu_Caption,$News_Show_No){
	@$sql_result = mysql_query("insert into top_menu_news (News_Caption,News_Show_No) VALUES(\"$Topmenu_Caption\",$News_Show_No)");
	$Type_ID = mysql_insert_id();
	return $sql_result;
}

function Rename_Topmenu($Rename_Topmenu_ID,$Topmenu_New_Caption,$News_Show_No){
	@$sql_result = mysql_query("UPDATE top_menu_news SET News_Caption=\"$Topmenu_New_Caption\",News_Show_No=$News_Show_No WHERE ID=$Rename_Topmenu_ID");
	return $sql_result;
}

function Delete_Topmenu($Delete_Topmenu_ID){
  	/*
	$row = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM top_menu_text 
										WHERE ((Type='NEWS') AND (Type_ID=$Delete_Topmenu_ID))"));
	if($row[0]==0)
	*/
		mysql_query("DELETE FROM top_menu_news WHERE ID=$Delete_Topmenu_ID");
}

function New_Topmenu_Form($ShowAsNewTopCategory,$roll_menu){
	if($ShowAsNewTopCategory=="YES")
		print "
			<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
			<tr>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
						<tr>
							<td>
								<input type=\"hidden\" value=\"NO\" name=\"ShowAsNewTopCategory\" />
								<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
								<input type=\"text\" value=\"".UTM_NAZOV."\" name=\"Top_Menu_Caption\" 
									style=\"width:160px;background-color:white;border:1px solid black;\" />
								<font style=\"font-size:10px;font-family:verdana;\">".UTM_PORADOVE_CISLO."</font>
								<input type=\"text\" value=\"0\" name=\"News_Show_No\" 
									style=\"width:20px;background-color:white;border:1px solid black;\" />
							</td>
							<td>
						    	<input type=\"submit\" value=\"".UTM_OK."\" style=\"width :50px;border:1px solid black;\"
						        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
						        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
						    </td>
						</tr>
					</form>
				</td>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<input type=\"hidden\" value=\"NO\" name=\"ShowAsNewTopCategory\" />
						<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
				    	<input type=\"submit\" value=\"".UTM_ZRUSIT."\" style=\"width :50px;border:1px solid black;\"
				        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
				        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
					</form>
				</td>
			<tr>
		</table>";		
	else
		print "
			<form action=\"news_creator.php\" method=\"post\">
				<input type=\"hidden\" value=\"".$sql_array_SMnu->ID."\" name=\"ID\" />
				<input type=\"hidden\" value=\"YES\" name=\"ShowAsNewTopCategory\" />
				<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
		    	<input type=\"submit\" value=\"".UTM_PRIDAT_KATEGORIU."\" style=\"width :160px;border:1px solid black;\"
		        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
		        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
			</form>";
}

function Rename_Topmenu_Form($ShowAsTopMenuUpdate,$ActualID,$roll_menu){
	if($ShowAsTopMenuUpdate==$ActualID){
		$Caption = mysql_fetch_array(mysql_query("SELECT News_Caption,News_Show_No  FROM top_menu_news WHERE ID=$ActualID"));
		print "
			<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
			<tr>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
							<tr>
								<td>
									<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
										<tr>
											<td>
												<font style=\"font-size:10px;font-family:verdana;\">".UTM_NAZOV."</font>
											</td>
											<td>
												<input type=\"text\" value=\"".$Caption["News_Caption"]."\" name=\"Topmenu_New_Caption\" 
													style=\"width:90px;background-color:white;border:1px solid black;\" />
											</td>
											<td>
												<font style=\"font-size:10px;font-family:verdana;\">".UTM_PORADOVE_CISLO."</font>
											</td>
											<td>
												<input type=\"text\" value=\"".$Caption["News_Show_No"]."\" name=\"News_Show_No\" 
													style=\"width:20px;background-color:white;border:1px solid black;\" />
											<td>
										</tr>
									</table>
								</td>
								<td>
									<input type=\"hidden\" value=\"NO\" name=\"ShowAsTopMenuUpdate\" />
									<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
									<input type=\"hidden\" value=\"".$ActualID."\" name=\"Rename_Topbmenu_ID\" />
							    	<input type=\"submit\" value=\"".UTM_OK."\" style=\"width :50px;border:1px solid black;\"
							        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
							        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
							    </td>
							</tr>
						</table>
					</form>
				</td>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<input type=\"hidden\" value=\"NO\" name=\"ShowAsTopMenuUpdate\" />
						<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
				    	<input type=\"submit\" value=\"".UTM_ZRUSIT."\" style=\"width :50px;border:1px solid black;\"
				        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
				        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
					</form>
				</td>
			</tr>
			</table>";
	}
	else
		print "
			<form action=\"news_creator.php\" method=\"post\">
				<input type=\"hidden\" value=\"".$sql_array_TMnu->ID."\" name=\"ID\" />
				<input type=\"hidden\" value=\"$ActualID\" name=\"ShowAsTopMenuUpdate\" />
				<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
		    	<input type=\"submit\" value=\"".UTM_UPRAVIT_NAZOV_KATEGORIE_NOVINKY."\" style=\"width :400px;border:1px solid black;text-align:center;\"
		        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
		        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
			</form>";
}

function Delete_Topmenu_Form($ShowAsTopMenuDelete,$ActualID,$roll_menu){
	if($ShowAsTopMenuDelete==$ActualID)
		print "
			<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
			<tr>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0px;\">
							<tr>
								<td>
									<font style=\"font-size:10px;font-family:verdana;\"><b>".UTM_NAOZAJ_ODSTRANIT."</b></font><br />
								</td>
								<td>
									<input type=\"hidden\" value=\"NO\" name=\"ShowAsTopMenuDelete\" />
								</td>
								<td>
									<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
									<input type=\"hidden\" value=\"".$ActualID."\" name=\"Delete_Topmenu_ID\" />
							    	<input type=\"submit\" value=\"".UTM_ANO."\" style=\"width :50px;border:1px solid black;\"
							        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
							        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
							    </td>
							</tr>
						</table>
					</form>
				</td>
				<td>
					<form action=\"news_creator.php\" method=\"post\">
						<input type=\"hidden\" value=\"NO\" name=\"ShowAsTopMenuDelete\" />
						<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
				    	<input type=\"submit\" value=\"".UTM_NIE."\" style=\"width :50px;border:1px solid black;\"
				        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
				        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
					</form>
				</td>
			</tr>
		</table>";		
	else
		print "
			<form action=\"news_creator.php\" method=\"post\">
				<input type=\"hidden\" value=\"".$sql_array_TMnu->ID."\" name=\"ID\" />
				<input type=\"hidden\" value=\"$ActualID\" name=\"ShowAsTopMenuDelete\" />
				<input type=\"hidden\" value=\"".$roll_menu."\" name=\"roll_menu\" />
		    	<input type=\"submit\" value=\"".UTM_ODSTRANIT."\" style=\"width :210px;border:1px solid black;text-align:center;\"
		        	onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
		        	onmouseout= \"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
			</form>";
}
?>